<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Set the structure flag in the search object</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="swishsearch.setsort.html">SwishSearch::setSort</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="refs.utilspec.server.html">针对服务器的扩展</a></div>
 <div class="up"><a href="ref.swish.html">Swish 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="swishsearch.setstructure" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SwishSearch::setStructure</h1>
  <p class="verinfo">(PECL swish &gt;= 0.1.0)</p><p class="refpurpose"><span class="refname">SwishSearch::setStructure</span> &mdash; <span class="dc-title">Set the structure flag in the search object</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-swishsearch.setstructure-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type"><span class="type void">void</span></span> <span class="methodname"><strong>SwishSearch::setStructure</strong></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$structure</code></span>
   )</div>

  <div class="warning"><strong class="warning">Warning</strong><p class="simpara">此函数是<em class="emphasis">实验性</em>的。此函数的表象，包括名称及其相关文档都可能在未来的
PHP 发布版本中未通知就被修改。使用本函数风险自担 。</p></div>
 </div>

 <div class="refsect1 parameters" id="refsect1-swishsearch.setstructure-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">structure</code></em></dt>

     <dd>

      <p class="para">
       The structure flag a bitmask is used to limit search to certain parts of HTML
       documents (like title, meta, body etc.). Its possible values are listed below. 
       To combine several values use bitwise OR operator, see example below.
      </p>
     </dd>

    
   </dl>

  </p>
  <p class="para">
   <ul class="itemizedlist">
    <li class="listitem">
     <p class="para">
      <strong><code>Swish::IN_FILE</code></strong>
     </p>
    </li>
    <li class="listitem">
     <p class="para">
      <strong><code>Swish::IN_TITLE</code></strong>
     </p>
    </li>
    <li class="listitem">
     <p class="para">
      <strong><code>Swish::IN_HEAD</code></strong>
     </p>
    </li>
    <li class="listitem">
     <p class="para">
      <strong><code>Swish::IN_BODY</code></strong>
     </p>
    </li>
    <li class="listitem">
     <p class="para">
      <strong><code>Swish::IN_COMMENTS</code></strong>
     </p>
    </li>
    <li class="listitem">
     <p class="para">
      <strong><code>Swish::IN_HEADER</code></strong>
     </p>
    </li>
    <li class="listitem">
     <p class="para">
      <strong><code>Swish::IN_EMPHASIZED</code></strong>
     </p>
    </li>
    <li class="listitem">
     <p class="para">
      <strong><code>Swish::IN_META</code></strong>
     </p>
    </li>
   </ul>
  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-swishsearch.setstructure-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   没有返回值。
  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-swishsearch.setstructure-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-4650">
    <p><strong>Example #1 Basic <span class="function"><strong>SwishSearch::setStructure()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">try&nbsp;{<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$swish&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Swish</span><span style="color: #007700">(</span><span style="color: #DD0000">"index.swish-e"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$search&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$swish</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">prepare</span><span style="color: #007700">();<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$results&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$search</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">execute</span><span style="color: #007700">(</span><span style="color: #DD0000">"time"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"First&nbsp;query&nbsp;found:&nbsp;"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$results</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">hits</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"&nbsp;hits\n"</span><span style="color: #007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$search</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setStructure</span><span style="color: #007700">(</span><span style="color: #0000BB">Swish</span><span style="color: #007700">::</span><span style="color: #0000BB">IN_TITLE</span><span style="color: #007700">|</span><span style="color: #0000BB">Swish</span><span style="color: #007700">::</span><span style="color: #0000BB">IN_HEAD</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//search&nbsp;in&nbsp;title&nbsp;and&nbsp;head<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$results&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$search</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">execute</span><span style="color: #007700">(</span><span style="color: #DD0000">"time"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Second&nbsp;query&nbsp;found:&nbsp;"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$results</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">hits</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"&nbsp;hits\n"</span><span style="color: #007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$search</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setStructure</span><span style="color: #007700">(</span><span style="color: #0000BB">Swish</span><span style="color: #007700">::</span><span style="color: #0000BB">IN_ALL</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//search&nbsp;in&nbsp;whole&nbsp;document,&nbsp;the&nbsp;default&nbsp;value<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$results&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$search</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">execute</span><span style="color: #007700">(</span><span style="color: #DD0000">"time"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Third&nbsp;query&nbsp;found:&nbsp;"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$results</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">hits</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"&nbsp;hits\n"</span><span style="color: #007700">;<br /><br />}&nbsp;catch&nbsp;(</span><span style="color: #0000BB">SwishException&nbsp;$e</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$e</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getMessage</span><span style="color: #007700">(),&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
First query found: 5 hits
Second query found: 0 hits
Third query found: 5 hits
</pre></div>
    </div>
   </div>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="swishsearch.setsort.html">SwishSearch::setSort</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="refs.utilspec.server.html">针对服务器的扩展</a></div>
 <div class="up"><a href="ref.swish.html">Swish 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
